/**
 * Copyright 2007-2008. Chongqing First Information & Network Co., Ltd. All
 * rights reserved. <a>http://www.cqfirst.com.cn</a>
 */
package com.cqcis.uip.base.framework.common;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.mina.common.IoSession;


/**
 * UIP服务端实现
 * 
 * @author huangmy
 * @date   2007-11-23
 */
public class UipServerImpl {
	private List<IoSession> sessions = new ArrayList<IoSession>();  /*客户端*/
	
	public String[] getSessions() {		
		List<String> list = new ArrayList<String>();
		
		for(Iterator<IoSession> it = sessions.iterator(); it.hasNext();) {
			IoSession session = it.next();
			
			list.add(session.getRemoteAddress().toString());
		}
		
		return (String[])list.toArray();
	}
	
	/**
	 * @param session
	 */
	public void incrementSessionCount(IoSession session) {		
		sessions.add(session);
	}
	
	/**
	 * @param session
	 */
	public void decrementSessionCount(IoSession session) {		
		sessions.remove(session);
	}
}
